/**
 * 载入文件
 * @returns {{loadHtml: loadHtml, loadJavaScript: loadJavaScript, loadCSS: loadCSS}}
 * @return loadHtml 载入Html页面，返回页面的内容
 * @return loadJavaScript 载入JavaScript文件，返回文件的内容this
 * @return loadCSS 载入CSS文件
 */
function commonLoadComponent() {
	var urlList = [];
	return {
		// 加载html页面内容
		loadHtml: function(url, successFun) {
			require(['lib/require/text!' + url], successFun);
		},
		// 加载JavaScript内容
		loadJavaScript: function(url, successFun) {
			require([url], successFun);
		},
		// 加载JavaScript内容
		loadJavaScriptByTag: function(url, successFun) {
			if(urlList.indexOf(url) == -1) {
				var script = document.createElement("script");
				script.type = "text/javascript";
				if(script.readyState) { // IE
					script.onreadystatechange = function() {
						if(script.readyState == "loaded" || script.readyState == "complete") {
							script.onreadystatechange = null;
							if(typeof successFun == "function") {
								successFun();
							}
						}
					};
				} else { // FF, Chrome, Opera, ...
					script.onload = function() {
						if(typeof successFun == "function") {
							successFun();
						}
					};
				}
				script.src = url;
				document.getElementsByTagName("head")[0].appendChild(script);
				urlList.push(url);
			}
		},
		// 加载CSS样式内容
		loadCSS: function(url, successFun) {
			require(['lib/require/css!' + url], successFun);
		},
		loadCSSByTag: function(cssUrls) {
			cssUrls = typeof cssUrls == "string" ? [cssUrls] : cssUrls;
			for(var i in cssUrls) {
				$("head").append("<link href=" + cssUrls[i] + " rel='stylesheet' type='text/css' />");
			}
		},
		// 加载vue组件文件
		loadVueComponentFile: function(url, successFun) {
			require(['lib/require/text!' + url + '.html', url], function(html, component) {
				component.template = html;
				successFun(component);
			});
		}
	}
}